﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArriviSoft.SlotMachine.Model
{
    public class SlotValidator: ISlotValidator
    {

        #region ISlotValidator Members

        private const int SEVEN = 4;
        private const int BELL = 3;
        private const int MELON = 2;
        private const int APPLE = 1;
        private const int CHERRY = 0;

        public Outcome Validate(int[] value, int items)
        {
            int prize = 0;


            if (value[0] == CHERRY) 
            {
                prize = 1;
            }

            if ((value[0] == CHERRY) && (value[1] == CHERRY))
            {
                prize = 2;
            }

            if ((value[0] == APPLE) && (value[1] == APPLE) && (value[2] == SEVEN))
            {
                prize = 8;
            }

            if ((value[0] == APPLE) && (value[1] == APPLE) && (value[2] == APPLE))
            {
                prize = 10;
            }

            if ((value[0] == MELON) && (value[1] == MELON) && (value[2] == SEVEN))
            {
                prize = 14;
            }

            if ((value[0] == MELON) && (value[1] == MELON) && (value[2] == MELON))
            {
                prize = 16;
            }

            if ((value[0] == BELL) && (value[1] == BELL) && (value[2] == SEVEN))
            {
                prize = 20;
            }

            if ((value[0] == BELL) && (value[1] == BELL) && (value[2] == BELL))
            {
                prize = 25;
            }

            if ((value[0] == SEVEN) && (value[1] == SEVEN) && (value[2] == SEVEN))
            {
                prize = 100;
            }

            return new Outcome(value, prize);
        }

        #endregion
    }
}
